#include<stdio.h>
#include <string.h>
int main()
{
    int i,n;
    printf("input n group");
    scanf("%d",&n);
    int flag=0;
    for(i=0;i<n;i++)
    {
        int a,b,c,x;
        scanf("%d %d %d",&a,&b,&c);
        1000<=x<=9999;
        for(;1<=a<=100;a++)
        {
            for(;1<=b<=100;b++)
            {
                for(;1<=c<=100;c++) {
                   if(x%a!=0&&(x+1)%b!=0&&(x+2)%c!=0) {
                   continue;
                   printf("%d\n",x);
                   flag=1;
                   }
                }
            }
        }
    }
            if(flag=0)
            printf("impossible\n");
    return 0;
}
